{{ include("common/header.html")}}

<div class="layui-container fly-marginTop">
  <div class="fly-panel fly-panel-user" pad20>
    <div class="layui-tab layui-tab-brief" lay-filter="user">
      <ul class="layui-tab-title">
        <li><a href="{{SUFFIX}}login.html">登入</a></li>
        <li class="layui-this">绑定账户</li>
      </ul>
      <div class="layui-form layui-tab-content" id="LAY_ucm" style="padding: 20px 0;">
        <div class="layui-tab-item layui-show">
          <div class="layui-form layui-form-pane">
            <form method="post">
              <div class="layui-form-item">
                <label for="L_email" class="layui-form-label">邮箱</label>
                <div class="layui-input-inline">
                  <input type="text" id="L_email" name="email" required lay-verify="email" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">将会成为您唯一的登入名</div>
              </div>
              <div class="layui-form-item">
                <label for="L_username" class="layui-form-label">用户名</label>
                <div class="layui-input-inline">
                  <input type="text" id="L_username" name="username" required lay-verify="required" autocomplete="off" class="layui-input" >

                </div>
              </div>
              <div class="layui-form-item">
                <label for="L_pass" class="layui-form-label">密码</label>
                <div class="layui-input-inline">
                  <input type="password" id="L_pass" name="password" required lay-verify="required" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">6到16个字符</div>
              </div>
              <div class="layui-form-item">
                <label for="L_repass" class="layui-form-label">确认密码</label>
                <div class="layui-input-inline">
                  <input type="password" id="L_repass" name="repass" required lay-verify="required" autocomplete="off" class="layui-input">
                </div>
              </div>
              <!-- <div class="layui-form-item">
                <div class="layui-form-item">
                  <label for="L_vercode" class="layui-form-label">验证码</label>
                  <div class="layui-input-inline">
                    <input type="text" id="L_vercode" name="vercode"  required lay-verify="required" placeholder="请回答后面的验证码" autocomplete="off" class="layui-input">
                  </div>
                  <div class="layui-form-mid" style="padding:0px 0!important;margin-top:-2.5px;">
                    <img  onclick="javascript:re_captcha();" src="{{ G.url('app/login/captcha') }}"  alt="验证码" title="刷新图片" width="100" height="45" id="c2c98f0de5a04167a9e427d883690ff6" border="0">
                  </div>
              </div> -->
              <div class="layui-form-item">
                <button class="layui-btn"  lay-submit lay-filter="formDemo">立即注册</button>
                <div class="layui-btn" id="skip">跳过</div>
              </div>
              <input type="hidden" id="openid" name="openid" value="{{content.openid}}" class="layui-input">
              <input type="hidden" id="nickname" name="nickname" value="{{content.nickname}}" class="layui-input">
              <input type="hidden" id="type" name="type" value="{{content.type}}" class="layui-input">              
          <!--    <div class="layui-form-item fly-form-app">
                <span>或者直接使用社交账号快捷注册</span>
                <a href="" onclick="layer.msg('正在通过QQ登入', {icon:16, shade: 0.1, time:0})" class="iconfont icon-qq" title="QQ登入"></a>
                <a href="" onclick="layer.msg('正在通过微博登入', {icon:16, shade: 0.1, time:0})" class="iconfont icon-weibo" title="微博登入"></a>
              </div>-->
            </form>
          </div>
        </div>
      </div>
    </div>
  </div>

</div>

<script>
    //Demo
    layui.use(['layer', 'form'], function(){
        var form = layui.form;

        //监听提交
        form.on('submit(formDemo)', function(data){

            var field=data.field;
            //console.log(field)
              $.ajax({
                  url:"{{G.url('app/registers/siginin')}}",//当前ajax请求的地址
                  type:'post',//请求的方式
                  async:true,//是否异步  默认为异步
                  data:field,//当前ajax请求的参数  
                  dataType:"json",
                  success: function(data){//发送成功时的代码执行
                    console.log(data)
                      if(data.code==2001){
                          if(data.data.email){
                              layer.msg("注册失败:"+data.data.email);
                          }else if(data.data.username){
                              layer.msg("注册失败:"+data.data.username);
                          }else if(data.data.password){
                              layer.msg("注册失败:"+data.data.password);
                          }else{
                              layer.msg("注册失败:"+JSON.stringify(data.data));
                          }
                          //re_captcha();
                          return false;
                      }
                      if(data.code==1001){
                          layer.msg(data.data+"正在跳转........");
                          setTimeout(function(){
                              window.location.href="{{G.url('app/index/index')}}";
                          }, 3000);

                      }else{
                          layer.msg("注册失败，请重新尝试注册");

                      }
                      //re_captcha();
                  },
                  error:function(){//失败时的代码执行
                      layer.msg("注册失败，请重新尝试注册");
                      //re_captcha();
                  }

              })
            return false;
        });
        $('#skip').click(function () {          
          
            openid=$("#openid").val()
            nickname=$("#nickname").val()
            type=$("#type").val()

              $.ajax({
                  url:"{{G.url('app/registers/siginin')}}",//当前ajax请求的地址
                  type:'post',//请求的方式
                  async:true,//是否异步  默认为异步
                  data:{openid:openid,nickname:nickname,type:type},//当前ajax请求的参数  
                  dataType:"json",
                  success: function(data){//发送成功时的代码执行
                    console.log(data)
                      if(data.code==2001){
                          if(data.data.email){
                              layer.msg("注册失败:"+data.data.email);
                          }else if(data.data.username){
                              layer.msg("注册失败:"+data.data.username);
                          }else if(data.data.password){
                              layer.msg("注册失败:"+data.data.password);
                          }else{
                              layer.msg("注册失败:"+JSON.stringify(data.data));
                          }
                          //re_captcha();
                          return false;
                      }
                      if(data.code==1001){
                        console.log(data)
                          layer.msg(data.data+"正在跳转........");
                          setTimeout(function(){
                              window.location.href="{{G.url('app/index/index')}}";
                          }, 3000);

                      }else{
                          layer.msg("注册失败，请重新尝试注册");

                      }
                      //re_captcha();
                  },
                  error:function(){//失败时的代码执行
                      layer.msg("注册失败，请重新尝试注册");
                      //re_captcha();
                  }

              })
            return false;
        
        })
    });
    
</script>
<script>

    /**
     * 刷新验证码
     */
    function re_captcha() {
        var url = "{{ G.url('app/login/captcha',{'captcha':'random'}) }}";
        var random = Math.random();
        url = url.replace("random", random);//使用js自带函数进行变量替换
        document.getElementById('c2c98f0de5a04167a9e427d883690ff6').src=url;
    }




</script>

{{ include("common/footer.html")}}
